package HuiWen;

import java.util.Scanner;

public class HuiWen {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个数：");
        int num = scanner.nextInt();

        boolean isHuiWen = isHuiWen(num);

        if (isHuiWen) {
            System.out.println(num + " 是回文数");
        } else {
            System.out.println(num + " 不是回文数");
        }
    }

    public static boolean isHuiWen(int num) {
        int originalNum = num;

        int reverseNum = 0;
        while (num != 0) {
            int remainder = num % 10;
            reverseNum = reverseNum * 10 + remainder;
            num /= 10;
        }

        return originalNum == reverseNum;
    }
}
